package com.study.mike.controller;

import com.study.mike.model.po.SaleProductPO;
import com.study.mike.model.po.ShelveSaleProductPO;
import com.study.mike.result.R;
import com.study.mike.result.RUtil;
import com.study.mike.service.SaleProductService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @author KangHui
 * @Date 2022/9/2 15:23
 */
@RestController
@RequestMapping("sale/product")
public class SaleProductController {
    @Resource
    private SaleProductService saleProductService;

    /**
     * 新增商品
     *
     * @param productPO
     * @return
     */
    @PostMapping("/add")
    public R addSaleProduct(@RequestBody @Valid SaleProductPO productPO) {
        return RUtil.success(saleProductService.addSaleProduct(productPO));
    }

    /**
     * 商品上架
     */
    @PostMapping("/shelve")
    public R shelveSaleProduct(@RequestBody @Valid ShelveSaleProductPO po) {
        return RUtil.success(saleProductService.shelveSaleProduct(po));
    }

    /**
     * 商品信息编辑
     *
     * @param productPO
     * @return
     */
    @PostMapping("/edit")
    public R editSaleProduct(@RequestBody @Valid SaleProductPO productPO) {
        return RUtil.success(saleProductService.editSaleProduct(productPO));
    }


}
